<template>
  <div>
    <div>
      <base-map-search
        ref="mapSearch"
        :city="form.city"
        :value="form.address"
        :longitude="form.longitude"
        :latitude="form.latitude"
        @updateLocation="updateLocation"
      />
    </div>
  </div>
</template>
<script>
import BaseMapSearch from "@/components/baseMapSearch";
export default {
  components: {
    BaseMapSearch
  },
  data() {
    return {
      form: {
	      city: "广东",
        address: "",
        longitude: "",
        latitude: ""
      },
    };
  },
  created() {
      let location =  sessionStorage.getItem('initLocation') && JSON.parse(sessionStorage.getItem('initLocation'))
      if (location) {
          this.form.longitude = location[0];
          this.form.latitude = location[1];
      }
  },
  methods: {
    // 地图搜索选址
    updateLocation(lng, lat, address) {
      sessionStorage.setItem('positons','');
      this.form.longitude = lng;
      this.form.latitude = lat;
      this.form.address = address;
      sessionStorage.setItem('positons',JSON.stringify(this.form))
    },
  }
};
</script>
